<template>
	<navbar title="收银台" :isBack="true"></navbar>
	<view class="" style="padding: 100rpx 30rpx 0 30rpx;display: flex;flex-direction: column;justify-content: center;align-items: center;">
		<view class="">
			支付金额
		</view>
		<view class="" style="font-weight: bold;margin-top: 36rpx;">
			<span style="font-size: 40rpx;line-height: 1.5;">￥</span>
			<span style="font-size: 72rpx;">{{Info.pay_price}}</span>
		</view>
		<view class="" style="margin-top: 100rpx;width: 100%;height: 112rpx;background-color: #F9F9F9;border-radius: 20rpx;display: flex;justify-content: space-between;align-items: center;padding-left: 20rpx;">
			<view class="" style="display: flex;align-items: center;">
				<image src="../../static/image/wx.png" style="width: 34rpx;height: 30rpx;" mode="aspectFill"></image>
				<view class="" style="margin-left: 10rpx;">
					微信支付
				</view>
			</view>
			<view class="">
				<u-radio-group v-model="radio">
					<u-radio active-color="#405EEC" name="radio"></u-radio>
				</u-radio-group>
			</view>
		</view>
		<view class="" @tap="pay" style="margin-top: 78rpx;width: 100%;height: 98rpx;display: flex;justify-content: center;align-items: center;background-color: #405EEC;color: white;font-size: 32rpx;border-radius: 52rpx;">
			确认支付
		</view>
	</view>
	
</template>

<script setup lang="ts">
	import { onLoad, onShareAppMessage, onShareTimeline, onReachBottom } from '@dcloudio/uni-app'
	import { reactive, ref } from 'vue'
			import { cashier,orderPay } from '@/service/api/index'
	import tools from '@/utils/tools'
	const radio =  ref('radio')
	const id = ref()
	const Info = ref({}) as any
	onLoad((opt)=>{
		id.value = opt.order_id;
		getData()
	})
	const getData = async()=>{
		const res = await cashier({id:id.value});
		console.log(res);
		Info.value = res.msg
	}
	const pay = async()=>{
		const res = await orderPay({id:id.value});
		console.log(res);
		tools.requestPayment(res.msg).then((res)=>{
			tools.showToast('支付成功')
			tools.navTo('/pagesA/pay/payResult?state=1&id=' + id.value,4)
				
		}).catch((err)=>{
			tools.showToast('取消支付')
			tools.navTo('/pagesA/pay/payResult?state=0&id=' + id.value,4)
		})
		 
	}
</script>

<style scoped lang="scss">
</style>